package com.hansming.bss.modules.sfc.service;

import java.util.Date;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hansming.bss.common.service.CrudService;
import com.hansming.bss.modules.sfc.dao.WxUserDao;
import com.hansming.bss.modules.sfc.entity.WxUser;

/**
 * 游客信息Service
 * @author Hansming
 * @version 2017-11-28
 */
@Service
@Transactional(readOnly = true)
public class WxUserService extends CrudService<WxUserDao,WxUser>{
	
	@Autowired
	private WxUserDao wxuserDao;
	
	//得到用户根据openid
	public WxUser getWxUserByOpenid(String openid){
		return wxuserDao.getWxUserByOpenid(openid);
	}
	
		
	//存入token关联openid
	@Transactional(readOnly = false)
	public void saveToken(String token,String openid,String datetime,String timeflag){
		wxuserDao.saveToken(token, openid, datetime, timeflag);
	}
	
	//根据token取出对应的时间
	public String gettimeBytoken(String token){
		return wxuserDao.gettimeBytoken(token);
	}
		
	//根据token去除对应openid
	public String getOpenidByToken(String token){
		return wxuserDao.getOpenidByToken(token);
	}

	//更新 token 时间
	@Transactional(readOnly = false)
	public void updatetime(String datetime,String token){
		 wxuserDao.updatetime(datetime, token);
	}
	
	//根据openid 拿出对应的token
	public String gettokenbyopenid(String openid){
		return wxuserDao.gettokenbyopenid(openid);
	}
	
	//根据openid拿到userid
	public	String getuseridbyopenid(String openid){
		return	wxuserDao.getuseridbyopenid(openid);
	}
	
	
	//增加验证码数据
	@Transactional(readOnly = false)
	public void insertUserCode(String uid,String code,String date,String flag){
		wxuserDao.insertUserCode(uid, code, date, flag);
	}
	
	@Transactional(readOnly = false)
	public void updatecode(String uid,String code,String date,String flag){
		wxuserDao.updatecode(uid, code, date, flag);
	}
		
	//更改验证码使用状态
	@Transactional(readOnly = false)
	public void updateflag(String uid,String code,String flag){
		wxuserDao.updateflag(uid, code, flag);
	}
	
	public String selectcode(String uid){
		return wxuserDao.selectcode(uid);
	}
	
	public Date chickcode(String uid,String code){
		return wxuserDao.chickcode(uid, code);
	}
}
